<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<link rel="stylesheet" href="../admin/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="../admin/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../admin/js/jquery.ztree.core-3.4.js"></script>
<script type="text/javascript" src="../admin/js/jquery.ztree.excheck-3.4.js"></script>
<!-- 	  <script type="text/javascript" src="../../../js/jquery.ztree.exedit-3.4.js"></script>-->
<SCRIPT type="text/javascript">
		<!--
		var setting = {
			check: {
				enable: true
			},
			view: {
				showLine: false
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};
		
		$(document).ready(function(){
			$.ajax({
				type:'post',//可选get
				url:'../../ajax/menu!tree.do',//这里是接收数据
				dataType:'json',
				success:function(data){
					$.fn.zTree.init($("#treeDemo"), setting, data);
				},
				error:function (XMLHttpRequest, textStatus, errorThrown) {     
						alert(errorThrown);     
						}     	
			});
			
			
			
		});
		function getChecked(){
			var zTree1 = $.fn.zTree.getZTreeObj("treeDemo");		
			var nodes = zTree1.getCheckedNodes(true);				
			//alert(nodes.length)
			//var selected=JSON.stringify(nodes);
		//alert(selected);
			var nodeStr;
			var arr = new Array(nodes.length);
			for(var i=0;i<nodes.length;i++){
			//alert(nodes[i].id);
			arr[i]=nodes[i].id;
			}
			nodeStr=arr.join();
			//alert(nodeStr);
		
			$("#menuIdList").val(nodeStr);
			//alert($("#menuIdList").val())
		}

		//-->
</SCRIPT>
<body>
<s:form  name="ActForm" namespace="/pages" method="post">
	<s:hidden name="id" value="%{page.result[actionName].id}"></s:hidden>
	<p>
		<label>角色名:</label>
		<s:textfield name="name" value="%{page.result[actionName].name}"></s:textfield>
	</p>
	<p>
		<label>备注:</label>
		<s:textfield name="remarks" value="%{page.result[actionName].remarks}"></s:textfield>
	</p>
	<div >
		<ul id="treeDemo" class="ztree"></ul>
	</div>
	<s:hidden id="menuIdList" name="menuIdList"></s:hidden>
	<s:if test="%{page.result[actionName]==null}">
		<s:submit value="保存" action="%{actionName}!saveMenu" namespace="/pages" onClick="getChecked()"/>
	</s:if>
	<s:else>
		<s:submit value="修改" action="%{actionName}!updateMenu" namespace="/pages" onClick="getChecked()"/>
	</s:else>
</s:form>
</body>
</html>